package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.mapper.SysUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.SysLogisticsMapper;
import com.ruoyi.system.domain.SysLogistics;
import com.ruoyi.system.service.ISysLogisticsService;

/**
 * 物流信息Service业务层处理
 *
 * @author ruoyi
 * @date 2024-07-25
 */
@Service
public class SysLogisticsServiceImpl implements ISysLogisticsService
{
    @Autowired
    private SysLogisticsMapper sysLogisticsMapper;
    @Autowired
    private SysUserMapper sysUserMapper;

    /**
     * 查询物流信息
     *
     * @param logisticsId 物流信息主键
     * @return 物流信息
     */
    @Override
    public SysLogistics selectSysLogisticsByLogisticsId(Long logisticsId)
    {
        return sysLogisticsMapper.selectSysLogisticsByLogisticsId(logisticsId);
    }

    /**
     * 查询物流信息列表
     *
     * @param sysLogistics 物流信息
     * @return 物流信息
     */
    @Override
    public List<SysLogistics> selectSysLogisticsList(SysLogistics sysLogistics)
    {
        LoginUser loginUser = SecurityUtils.getLoginUser();
        SysUser user = sysUserMapper.selectUserById(loginUser.getUserId());
        sysLogistics.setSupplierId(user.getSupplierId());
        return sysLogisticsMapper.selectSysLogisticsList(sysLogistics);
    }

    /**
     * 新增物流信息
     *
     * @param sysLogistics 物流信息
     * @return 结果
     */
    @Override
    public int insertSysLogistics(SysLogistics sysLogistics)
    {
        return sysLogisticsMapper.insertSysLogistics(sysLogistics);
    }

    /**
     * 修改物流信息
     *
     * @param sysLogistics 物流信息
     * @return 结果
     */
    @Override
    public int updateSysLogistics(SysLogistics sysLogistics)
    {
        return sysLogisticsMapper.updateSysLogistics(sysLogistics);
    }

    /**
     * 批量删除物流信息
     *
     * @param logisticsIds 需要删除的物流信息主键
     * @return 结果
     */
    @Override
    public int deleteSysLogisticsByLogisticsIds(Long[] logisticsIds)
    {
        return sysLogisticsMapper.deleteSysLogisticsByLogisticsIds(logisticsIds);
    }

    /**
     * 删除物流信息信息
     *
     * @param logisticsId 物流信息主键
     * @return 结果
     */
    @Override
    public int deleteSysLogisticsByLogisticsId(Long logisticsId)
    {
        return sysLogisticsMapper.deleteSysLogisticsByLogisticsId(logisticsId);
    }
}
